package com.gexiaobao.pigeon.ui.dialog

import android.content.Context
import android.content.DialogInterface
import android.view.LayoutInflater
import android.widget.Button
import android.widget.TextView
import com.gexiaobao.pigeon.R
import kotlin.system.exitProcess

/**
 * @author tamsiree
 * @date 2016/7/19
 * 确认 弹出框
 */
class PrivacyDialog : RxDialog {

    lateinit var btnExit: Button
        private set
    lateinit var btnAgree: Button
        private set
    lateinit var tvContent: TextView
        private set

    constructor(context: Context?, themeResId: Int) : super(context!!, themeResId) {
        initView()
    }

    constructor(
            context: Context?,
            cancelable: Boolean,
            cancelListener: DialogInterface.OnCancelListener?
    ) : super(context!!, cancelable, cancelListener) {
        initView()
    }

    constructor(context: Context?) : super(context!!) {
        initView()
    }

    constructor(context: Context?, alpha: Float, gravity: Int) : super(context, alpha, gravity) {
        initView()
    }


    fun setContent(str: String?) {
        tvContent.text = str
    }

    private fun initView() {
        val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_privacy, null)
        btnExit = dialogView.findViewById(R.id.btn_exit)
        btnAgree = dialogView.findViewById(R.id.btn_agree)
        tvContent = dialogView.findViewById(R.id.tv_content)

        btnExit.setOnClickListener {
            dismiss()
            exitProcess(0)
        }
        setContentView(dialogView)
    }

}